package tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.LinkedList;
import java.util.List;

import org.junit.Test;

import urbanparks.Volunteer;

/**
 * Tests for the Volunteer class.
 * 
 * @author Dallas Rosson
 * @version 1.0 2/29/2012
 */
public class VolunteerTest {
  
  /**
   * The default Volunteer.
   */
  Volunteer my_vol = new Volunteer("Jean", "Grey", 
                                "IAmThePheonix@CosmicPower.org", 
                                 2, "555-555-1234", false);
  
  
  /**
   * Tests whether a Volunteer is created properly with
   * only one phone number passed in.
   */
  @Test
  public void testVolunteerCreationOneNumber() {
    
    String number;
    
    Volunteer vol = new Volunteer("Jean", "Grey", 
                                  "MarvelGirl@hard_thinkers.org", 
                                   2, "555-555-1234", false);
    
    assertEquals("First name incorrect!", "Jean", vol.getFirstName());
    assertEquals("Last name incorrect!", "Grey", vol.getLastName());
    assertEquals("Email incorrect!", "MarvelGirl@hard_thinkers.org", vol.getEmailAddress());
    assertEquals("Permission level incorrect!", 2, vol.getPermissionLevel());
    
    number = vol.getContactNumber();
    
    assertEquals("Phone number incorrect!", "555-555-1234", number);
    
    assertFalse(vol.isBlackballed());
    
  }
  
  /**
   * Tests whether a Volunteer is created properly with
   * only one phone number passed in.
   */
  @Test
  public void testVolunteerCreationMultNumber() {
    
    List<String> number = new LinkedList<String>();
    number.add("555-555-5551");
    number.add("555-555-5552");
    
    Volunteer vol = new Volunteer("Jean", "Grey", 
                                  "MarvelGirl@hard_thinkers.org", 
                                   2, number, false);
    
    assertEquals("First name incorrect!", "Jean", vol.getFirstName());
    assertEquals("Last name incorrect!", "Grey", vol.getLastName());
    assertEquals("Email incorrect!", "MarvelGirl@hard_thinkers.org", vol.getEmailAddress());
    assertEquals("Permission level incorrect!", 2, vol.getPermissionLevel());
    
    assertEquals("Phone number incorrect!", "555-555-5551", number.get(0));
    assertEquals("Phone number incorrect!", "555-555-5552", number.get(1));
    
    assertFalse(vol.isBlackballed());
    
  }
  
  /**
   * Tests that a volunteer reports blackballed when blackballed
   * status is set to "TRUE".
   */
  @Test
  public void testBlackBallStatus() {
    
    assertFalse(my_vol.isBlackballed());
    
    my_vol.blackball();
    
    assertTrue(my_vol.isBlackballed());
    
  }
  
  /**
   * Tests that phone numbers can be added to a volunteer.
   */
  @Test
  public void testAddPhoneNumber() {
     
    my_vol.addContactNumber("555-555-4321");
    
    
    assertEquals("Number not added properly.", "555-555-4321", 
                  my_vol.getContactNumber());    
    
  }

}
